package com.ruoyi.gbase.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gbase.domain.TProcExecStatus;
import com.ruoyi.gbase.service.ITProcExecStatusService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务日志Controller
 * 
 * @author YYS
 * @date 2025-01-21
 */
@RestController
@RequestMapping("/gbase/exec")
public class TProcExecStatusController extends BaseController
{
    @Autowired
    private ITProcExecStatusService tProcExecStatusService;

    /**
     * 查询任务日志列表
     */
    @PreAuthorize("@ss.hasPermi('gbase:exec:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProcExecStatus tProcExecStatus)
    {
        startPage();
        List<TProcExecStatus> list = tProcExecStatusService.selectTProcExecStatusList(tProcExecStatus);
        return getDataTable(list);
    }

    /**
     * 导出任务日志列表
     */
    @PreAuthorize("@ss.hasPermi('gbase:exec:export')")
    @Log(title = "任务日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TProcExecStatus tProcExecStatus)
    {
        List<TProcExecStatus> list = tProcExecStatusService.selectTProcExecStatusList(tProcExecStatus);
        ExcelUtil<TProcExecStatus> util = new ExcelUtil<TProcExecStatus>(TProcExecStatus.class);
        util.exportExcel(response, list, "任务日志数据");
    }

    /**
     * 获取任务日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('gbase:exec:query')")
    @GetMapping(value = "/{procExecDt}")
    public AjaxResult getInfo(@PathVariable("procExecDt") String procExecDt)
    {
        return success(tProcExecStatusService.selectTProcExecStatusByProcExecDt(procExecDt));
    }

    /**
     * 新增任务日志
     */
    @PreAuthorize("@ss.hasPermi('gbase:exec:add')")
    @Log(title = "任务日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProcExecStatus tProcExecStatus)
    {
        return toAjax(tProcExecStatusService.insertTProcExecStatus(tProcExecStatus));
    }

    /**
     * 修改任务日志
     */
    @PreAuthorize("@ss.hasPermi('gbase:exec:edit')")
    @Log(title = "任务日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProcExecStatus tProcExecStatus)
    {
        return toAjax(tProcExecStatusService.updateTProcExecStatus(tProcExecStatus));
    }

    /**
     * 删除任务日志
     */
    @PreAuthorize("@ss.hasPermi('gbase:exec:remove')")
    @Log(title = "任务日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{procExecDts}")
    public AjaxResult remove(@PathVariable String[] procExecDts)
    {
        return toAjax(tProcExecStatusService.deleteTProcExecStatusByProcExecDts(procExecDts));
    }
}
